import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useCounterStore = defineStore('counter', () => {
    // 1. 定义全局共享状态
    const count = ref(0)

    const num1 = ref(0)
    const num2 = ref(0)

    // 2. 定义操作数据的方法
    const add = () => count.value++
    const sub = () => count.value--

    return { count, num1, num2, add, sub }
}, {
    unistorage: {
        key: "cp-counter",
        paths: ["count"]
    }
})